package com.zking.utils;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;

import com.zking.dao.domain.SysUser;
import com.zking.dao.domain.User;

public class RequestUtils {

	// private static Logger logger = LoggerFactory.getLogger(RequestUtils.class);

	/**
	 * 获取当前登录的用户，若用户未登录，则返回未登录 json
	 * 
	 * @return
	 */
	public static SysUser currentLoginUser() {
		Subject subject = SecurityUtils.getSubject();
		if (subject.isAuthenticated()) {
			Object principal = subject.getPrincipals().getPrimaryPrincipal();
			if (principal instanceof SysUser) {
				return (SysUser) principal;
			}
		}
		return null;
	}
	/**
	 * 获取当前登录的用户，若用户未登录，则返回未登录 json
	 * 
	 * @return
	 */
	public static User MycurrentLoginUser() {
		Subject subject = SecurityUtils.getSubject();
		if (subject.isAuthenticated()) {
			Object principal = subject.getPrincipals().getPrimaryPrincipal();
			if (principal instanceof User) {
				return (User) principal;
			}
		}
		return null;
	}
}
